package ComputerOrganization.ComputerOrganizationWithInterface;

/**
 * @Author maojiangyue
 * @Date 2025/10/22
 * @Description 由配件组成的计算机类
 */
public class Computer {
    private CPU cpu;
    private Memory memory;
    private HardDisk hardDisk;

    public void setCpu(CPU cpu) {
        this.cpu = cpu;
    }

    public void setMemory(Memory memory) {
        this.memory = memory;
    }

    public void setHardDisk(HardDisk hardDisk) {
        this.hardDisk = hardDisk;
    }

    public void powerOn() {
        if (cpu != null && memory != null && hardDisk != null) {
            System.out.println("开机成功");
            System.out.println("CPU [ "+cpu.getCPUModel()
                    +" "+cpu.getFrequency()+" GHz ] 启动成功");
            System.out.println("内存 [ "+memory.getMemoryModel()
                    +" "+memory.getMemoryCapacity()+" GB ] 正在运行");
            System.out.println("硬盘 [ "+hardDisk.getHardDiskModel()
                    +" "+hardDisk.getHardDiskCapacity()+" GB ] 正在读取数据");
        }else{
            System.out.println("无法启动，请检查硬件是否完全装配");
        }
    }
}
